package cliente_diseno2011;

import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.JPanel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.JTextPane;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JButton;

public class Confirmacion extends JPanel {

	/**
	 * Create the panel.
	 */
	JButton btnConfirmarVoto;
	JTextPane textPane;
	JButton btnCancelar;

	public Confirmacion(ArrayList<Eleccion> eleccion) {

		JLabel lblConfirmacionDelVoto = new JLabel("Confirmacion del Voto");

		textPane = new JTextPane();
		textPane.setEditable(false);
		String contenido = new String("");
		for (Eleccion e : eleccion) {
			contenido += e.getEtapa() + "  " + e.getEleccion() + '\n';
		}
		textPane.setText(contenido);
		btnConfirmarVoto = new JButton("Confirmar Voto");

		btnCancelar = new JButton("Cancelar");
		GroupLayout groupLayout = new GroupLayout(this);
		groupLayout
				.setHorizontalGroup(groupLayout
						.createParallelGroup(Alignment.LEADING)
						.addGroup(
								groupLayout
										.createSequentialGroup()
										.addGroup(
												groupLayout
														.createParallelGroup(
																Alignment.LEADING)
														.addGroup(
																groupLayout
																		.createSequentialGroup()
																		.addGap(161)
																		.addComponent(
																				lblConfirmacionDelVoto))
														.addGroup(
																groupLayout
																		.createSequentialGroup()
																		.addGap(55)
																		.addComponent(
																				textPane,
																				GroupLayout.PREFERRED_SIZE,
																				322,
																				GroupLayout.PREFERRED_SIZE)))
										.addContainerGap(73, Short.MAX_VALUE))
						.addGroup(
								Alignment.TRAILING,
								groupLayout
										.createSequentialGroup()
										.addGap(32)
										.addComponent(btnCancelar)
										.addPreferredGap(
												ComponentPlacement.RELATED,
												188, Short.MAX_VALUE)
										.addComponent(btnConfirmarVoto)
										.addGap(36)));
		groupLayout.setVerticalGroup(groupLayout.createParallelGroup(
				Alignment.LEADING)
				.addGroup(
						groupLayout
								.createSequentialGroup()
								.addGap(23)
								.addComponent(lblConfirmacionDelVoto)
								.addPreferredGap(ComponentPlacement.RELATED)
								.addComponent(textPane,
										GroupLayout.PREFERRED_SIZE, 197,
										GroupLayout.PREFERRED_SIZE)
								.addGap(18)
								.addGroup(
										groupLayout
												.createParallelGroup(
														Alignment.BASELINE)
												.addComponent(btnConfirmarVoto)
												.addComponent(btnCancelar))
								.addContainerGap(19, Short.MAX_VALUE)));
		setLayout(groupLayout);

	}

	public void addConfirmarListener(ActionListener al) {
		btnConfirmarVoto.addActionListener(al);

	}

	public void addCancelarListener(ActionListener al) {
		btnCancelar.addActionListener(al);

	}

}
